package server.startup;

import server.Host;
import server.Lifecycle;
import server.connector.http.HttpConnector;
import server.core.*;

public class BootStrap {
    public static void main(String[] args) {
        HttpConnector connector = new HttpConnector();
        Host host = new StandardHost();

        StandardContext context1 = new StandardContext();
        context1.setName("context_app1");
        //添加监听器
        context1.addLifecycleListener(new SimpleContextConfig());

        StandardContext context2 = new StandardContext();
        context2.setName("app2");
        context2.addLifecycleListener(new Context2Config());

        host.addChild(context1);
        host.addChild(context2);

        connector.setContainer(host);
        try {
            connector.initialize();
            connector.start();
            ((Lifecycle)host).start();
            System.in.read();
            ((Lifecycle)host).stop();
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }


}
